<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>项目产品报价方案</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
    var update = '${update}';
    console.log("资管支付表管理列表update:" + update);

    var grid = null;
    //声明变量
    var ligerGrid;
    $(function () {
        initGrid();//grid
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            ligerGrid.toggleCol('thdPayDt', false);
            ligerGrid.toggleCol('thdPayAmt', false);
            for (name in data){
                if("paySchTypCd" == name){
                    if("ZF" == data[name]){
                        //false不显示，true显示
                        ligerGrid.toggleCol('thdPayDt', true);
                        ligerGrid.toggleCol('thdPayAmt', true);
                    }
                }
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });
        initCondition();
    });

    function initCondition(){}

    function clearBtn(){
        $("#searchBar").ligerForm();
        var form = new liger.get("searchBar");
        form.setData({
            lsCntNo:"",             //合同编号
            cstNm:"",               //承租人名称
            insCode:"",             //第三方机构
            strDate:"",             //起租日(起始时间)
            endDate:"",             //起租日(结束时间)
            isEnable:""            //支付表启用状态
            //paySchTypCd:""          //支付表类型(必选)
        });
    }
    //初始化列表
    function initGrid(){
        var params = {};

        if(update=="0"){
            $("#transFlg").val(1);
            params = {
                transFlg:1
            };
        }

        ligerGrid = $("#grid").ligerGrid({
            url: '<%=path%>/project/prjprdpayschm/getPrjPrdZfPaySchMList.do',
            method : 'get',
            parms:params,
            columns: [
                { display: '合同编号', name: 'lsCntNo', minWidth: 150 ,align:'left',enabledSort:true},
                { display: '支付表号', name: 'paySchNo', minWidth: 200,align:'left',
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h='<a href="javascript:detailBtn(';
                        h+="'"+rowdata.prjPrdDtlId+"',";
                        h+="'"+rowdata.id+"',";
                        h+="'"+rowdata.prjPrdId+"',";
                        h+="'"+rowdata.prjId+"'";
                        h+=')">'+value+'</a>'
                        return h;
                    },
                    enabledSort:true},
                { display: '承租人名称', name: 'cstNm', minWidth: 80,align:'left',enabledSort:true},
                { display: '第三方机构', name: 'fundRasInsNm', minWidth: 80,align:'left',enabledSort:true},
                { display: '起租日', name: 'lsDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true},
                { display: '机构实际放款时间', name: 'thdPayDt', id:"thdPayDt",minWidth: 80,align:'left',render:renderDate,enabledSort:true},
                { display: '机构实际放款金额', name: 'thdPayAmt', id:'thdPayAmt',minWidth: 80,align:'left',enabledSort:true,
                    render:function(rowdata,index,value){
                        if(rowdata.thdPayAmt){
                            return '&yen;'+FormatMoney(rowdata.thdPayAmt/100);
                        }
                    }
                },
                { display: '支付表启用状态', name: 'isEnable', minWidth: 80,align:'left',render:rederPaySchTypCd,enabledSort:true},
                { display: '操作', name: '查看还款情况', minWidth: 200,align:'left',
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h='<a href="javascript:payDetail(';
                        h+="'"+rowdata.id+"',";
                        h+=')">'+'查看还款情况'+'</a>'

                        if(rowdata.thdPayDt!='' && rowdata.thdPayDt!=null && rowdata.insCode == "ylbank" && rowdata.paySchTypCd=='ZF'){
                            h+='<a class="sq-button-hasicon" href="javascript:withholdRecord(';
                            h+="'"+rowdata.prjId+"'";
                            h+=')"><i class="sqBtnIco_4"></i>划扣记录查询</a>';
                        }
                        return h;
                    },
                    enabledSort:true},
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            checkbox:true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers:true,
            enabledEdit: false,
            fixedCellHeight: false,
            usePagerOnLessPagesize: true,
        });
        //false不显示，true显示
        ligerGrid.toggleCol('thdPayDt', false);
        ligerGrid.toggleCol('thdPayAmt', false);
        grid = liger.get("grid");
        grid.setHeight(300);
    }

    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value&&value!=''){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    //转化支付表是否开启标志 0-否，1-是
    function rederPaySchTypCd(rowdata,index,value){
        var paySchTypCdStr = "";
        if("0" == value){
            paySchTypCdStr = "否";
        }
        if("1" == value){
            paySchTypCdStr = "是";
        }
        return paySchTypCdStr;
    }

    function payDetail(id){
        //资管支付表标志
        var zfFlag = "true";
        var payDetailUrl = '<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPage.do?id='+id+'&&zfFlag='+zfFlag;
        Add_navTab('tab_prj_quat_prps_pay'+id,'查看还款情况',payDetailUrl);
    }

    function withholdRecord(prjId){
        var withholdRecordlUrl = '<%=path%>/project/prjprdpayschm/toWithholdRecordPage.do?prjId='+prjId;
        Add_navTab('tab_withhold_record'+prjId,'查看划扣记录',withholdRecordlUrl);
    }

    var onSave = function (item, Dialog) {
        //在子页面里绑定 frameElement.dialog.onOk = function () {}
        if (Dialog.onSave) Dialog.onSave();
    };

    var onCancel = function (item, Dialog) {
        //在子页面里绑定 frameElement.dialog.onOk = function () {}
        if (Dialog.onCancel) Dialog.onCancel();
    };

    function detailBtn(prjPrdDtlId,id,prjPrdId,prjId){
        var detailFlag = true;
        var zfDetailFlag = true;
        Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag=' + detailFlag + '&&zfDetailFlag='+zfDetailFlag);
    }

    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        };
    }

    var callback = function () {
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
            grid.setParm(name,data[name]);
        };
        grid.reload();
    };

</script>

<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div class="searchArea">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <input id="transFlg" name="transFlg" style="display:none"/>
                        <div class="fieldBox col_33" >
                            <div class="label">合同编号</div>
                            <div class="field">
                                <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33" >
                            <div class="label">承租人名称</div>
                            <div class="field">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33" id="searchInsCodeId" <sys:resourceAuth resCd="noThdOrg">style="display: none" </sys:resourceAuth>>
                            <div class="label">第三方机构</div>
                            <div class="field">
                                <select name="insCode"  id="insCode" >
                                    <option value="" selected="selected">请选择</option>
                                    <c:forEach items="${friBaseList}" var="fri">
                                        <option value="${fri.insCode}">${fri.fundRasInsNmShow}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">起租日</div>
                            <div class="field">
                                <input name="strDate" id="strDate" type="text" class="ui-datepicker" value="">
                                <span>---</span>
                                <input name="endDate" id="endDate" type="text" class="ui-datepicker" value="">
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">支付表启用状态</div>
                            <div class="field">
                                <select name="isEnable"  id="isEnable"  >
                                    <option value="  " selected="selected">--请选择--</option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">支付表类型</div>
                            <div class="field">
                                <select name="paySchTypCd"  id="paySchTypCd" >
                                    <option value="WS">我司支付表</option>
                                    <option value="ZF">资方支付表</option>
                                    <option value="BF">备份支付表</option>
                                    <option value="SH">赎回支付表</option>
                                </select>
                            </div>
                        </div>
                        <div class="clearFix"></div>
                        <div class="btnsBox">
                            <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
                            <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                        </div>
                    </div>
                </form>
            </div>
            <div id="grid" class="sq-grid"></div>
        </div>
    </div>
</div>
</body>
</html>